package com.sh_rw.label.bean;

/**
 *
 * 状态位实体类
 * 所有字段都为 1 位
 * Created by rw-duke on 2017/10/10.
 */

public class StatusBean {

    private char active_region ='0';//激活区    0：表示不在激活区  1：表示在激活区
    private char voltage='0';//电压   0：表示电压正常    1：表示电压低
    private char anti_dismantle='0';//防拆    0：防拆正常  1：防拆异常
    private char button='0';//按钮    0：按钮按下  1：按钮没按下
    private char vibrating_sensor='0';//振动传感器   0：无振动   1：振动
    private char retain='0';//保留
    private char open_receive='0';//打开接收    0：接收关闭  1：接收打开
    private char electricity_sign='0';//上电标志    0：正常    1：上电（复位防拆时清零）


    public StatusBean() {
    }

    public StatusBean(char active_region, char voltage, char anti_dismantle, char button, char vibrating_sensor, char retain, char open_receive, char electricity_sign) {
        this.active_region = active_region;
        this.voltage = voltage;
        this.anti_dismantle = anti_dismantle;
        this.button = button;
        this.vibrating_sensor = vibrating_sensor;
        this.retain = retain;
        this.open_receive = open_receive;
        this.electricity_sign = electricity_sign;
    }

    public StatusBean(byte b) {
        int i = b&0xff;
        String s1 = Integer.toBinaryString(i);
        int len = 8-s1.length();
        StringBuilder sb = new StringBuilder();
        if (s1.length()<8){
            for (int j = 0; j < len; j++) {
                sb.append("0");
            }
        }
        sb.append(s1);
        char[] binary = sb.toString().toUpperCase().toCharArray();
        this.active_region = binary[0];
        this.voltage = binary[1];
        this.anti_dismantle = binary[2];
        this.button = binary[3];
        this.vibrating_sensor = binary[4];
        this.retain = binary[5];
        this.open_receive = binary[6];
        this.electricity_sign = binary[7];
    }

    public char getActive_region() {
        return active_region;
    }

    public void setActive_region(char active_region) {
        this.active_region = active_region;
    }

    public char getVoltage() {
        return voltage;
    }

    public void setVoltage(char voltage) {
        this.voltage = voltage;
    }

    public char getAnti_dismantle() {
        return anti_dismantle;
    }

    public void setAnti_dismantle(char anti_dismantle) {
        this.anti_dismantle = anti_dismantle;
    }

    public char getButton() {
        return button;
    }

    public void setButton(char button) {
        this.button = button;
    }

    public char getVibrating_sensor() {
        return vibrating_sensor;
    }

    public void setVibrating_sensor(char vibrating_sensor) {
        this.vibrating_sensor = vibrating_sensor;
    }

    public char getRetain() {
        return retain;
    }

    public void setRetain(char retain) {
        this.retain = retain;
    }

    public char getOpen_receive() {
        return open_receive;
    }

    public void setOpen_receive(char open_receive) {
        this.open_receive = open_receive;
    }

    public char getElectricity_sign() {
        return electricity_sign;
    }

    public void setElectricity_sign(char electricity_sign) {
        this.electricity_sign = electricity_sign;
    }


    @Override
    public String toString() {
        return
                "active_region=" + active_region +
                "\\t voltage=" + voltage +
                "\\t anti_dismantle=" + anti_dismantle +
                "\\t button=" + button +
                "\\t vibrating_sensor=" + vibrating_sensor +
                "\\t retain=" + retain +
                "\\t open_receive=" + open_receive +
                "\\t electricity_sign=" + electricity_sign ;
    }
}
